#ifndef _MULTIPARTWRITER_HPP_
#define _MULTIPARTWRITER_HPP_

#include "jhdefs.hpp"

#include <ostream>
#include <string>

NET_NAMESPACE_BEGIN

class CMessageHeader;
class CMultipartWriter
{
public:
	explicit CMultipartWriter(std::ostream& ostr);
	CMultipartWriter(std::ostream& ostr, const std::string& boundary);
	~CMultipartWriter();

	void nextPart(const CMessageHeader& header);
	void close();
	std::ostream& stream();
	const std::string& boundary() const;
	static std::string createBoundary();

private:
	CMultipartWriter();
	CMultipartWriter(const CMultipartWriter&);
	CMultipartWriter& operator = (const CMultipartWriter&);

	std::ostream& m_ostr;
	std::string   m_boundary;
	bool          m_firstPart;
};

NET_NAMESPACE_END

#endif
